﻿// copyright @ 2009 Farida

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace ConsoleApplication1
{
    class ConnectToMySql

    {
        static void Main(string[] args)
        {
         // Create a MySql Connection with a query 
         bool sucess = false;
         string retValue;

         try
         {

             //create a MySQL connection with a query string
             MySqlConnection connection = new MySqlConnection("server=localhost;database=epoms;uid=root");
             Console.WriteLine("Server Connected");


             connection.Open();
             sucess = true;

             string Query = "select * from emp_vac";

             MySqlCommand cmd = new MySqlCommand(Query, connection);

             cmd.ExecuteNonQuery();

             MySqlDataReader myReader = cmd.ExecuteReader();

             while (myReader.Read() != false)
             {

                 retValue = myReader.GetString(1);


             }

             myReader.Close();


         }


         catch (Exception excp)
         {
             Exception myExcp = new Exception("Error connecting you to " +
                      "the my sql server. Error: " + excp.Message, excp);
             throw myExcp;

         }

         
        if (sucess)
        {
          Console.WriteLine("Successful Connection !!!");

        }
      }
  }
}

